<?php require_once(dirname(__FILE__).'/inc/config.inc.php');
IsModelPriv('member'); 
$action = isset($action) ? $action : '';
$typeid = isset($typeid) ?  $typeid : 'nickname'; // 提交类型
$u_level = isset($u_level) ? $u_level : '-1';  //权限
$keyword = isset($keyword) ? $keyword : ''; //关键词
?>
<style>
    .order-item {
        border: 1px solid transparent;
        margin-bottom: 1rem;
    }

    .order-item table {
        margin: 0;
    }

    .order-item:hover {
        border: 1px solid #3c8ee5;
    }

    .goods-item {
        margin-bottom: .75rem;
    }

    .goods-item:last-child {
        margin-bottom: 0;
    }

    .goods-pic {
        width: 5.5rem;
        height: 5.5rem;
        display: inline-block;
        background-color: #ddd;
        background-size: cover;
        background-position: center;
        margin-right: 1rem;
    }

    .goods-name {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
    }

    .order-tab-1 {
        width: 40%;
    }

    .order-tab-2 {
        width: 20%;
        text-align: center;
    }

    .order-tab-3 {
        width: 10%;
        text-align: center;
    }

    .order-tab-4 {
        width: 20%;
        text-align: center;
    }

    .order-tab-5 {
        width: 10%;
        text-align: center;
    }

    .status-item.active {
        color: inherit;
    }
.mr-5{    margin-right: 3rem!important;}
.presentation{ display:block; background:#666;}
.active{color: #fff !important;
    background-color: #337ab7 !important;}
</style>
</head>
<body>

<div class="toolbarTab">
  <div class="row tool2">
    <div class="col-md-1">
      <div class="tool1"><span class="btn btn-success" onClick="getMemberAll()"><span class="fa fa-bars" title="icon name" aria-hidden="true"></span> 所有用户</span></div>
    </div>
    <div class="col-md-5">
      <div class="s-label"> 查询条件：</div>
      <select class="form-control w100" name="typeidd" id="typeidd" onChange="getSelType()">
        <option value="nickname" <?php if($typeid=='nickname'){ echo "selected"; }?> >昵称</option>
        <option value="uid" <?php if($typeid=='uid'){ echo "selected"; }?>>ID</option>
        <option value="truename" <?php if($typeid=='truename'){ echo "selected"; }?>>姓名</option>
        <option value="mobile" <?php if($typeid=='mobile'){ echo "selected"; }?>>手机</option>
      </select>
      <input type="hidden" name="typeid" id="typeid" value="<?php echo $typeid;?>">
        <input type="text" class="form-control w200" name="keyword" id="keyword" title="输入搜索"
                   value="<?php echo $keyword; ?>">
    </div>
    <div class="col-md-2"> <a href="javascript:;" onClick="GetSearchMember();" class="btn btn-danger"><i class="fa fa-search"></i> 搜索</a> </div>
  </div>
</div>
<form name="form" id="form" method="post" action="member_save.php">
<ul id="myTabs" class="nav nav-tabs status">
    <li class="nav-item"><a class="status-item nav-link <?php if ($u_level == '-1') {   echo "active";  } ?> > " href="javascript:;" onClick="getJindu(-1)">所有用户</a></li>
    <?php 
	  $dosql->Execute("SELECT * FROM `#@__usergroup`   ORDER BY id asc");
	  while($row3 = $dosql->GetArray())
	  {
		  if($u_level==$row3['id']){
			   $checked='active';
	 		}else{
				$checked='';
			}
		  echo '<li class="nav-item"><a class="status-item nav-link  '.$checked.' " href="javascript:;" onclick="getMemberLevel('.$row3['id'].')">'.$row3['groupname'].'</a></li>';
	  }
  
	?>

        
</ul>
<input type="hidden" id="u_level" name="u_level" value="<?php echo $u_level; ?>">
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="dataTable table table-striped table-bordered">
    <tr align="left" class="head">
      <td width="3%">ID</td>
      <td width="6%" class="text-center">头像</td>
      <td width="10%" class="text-center">用户标识</td>
      <td width="8%" class="text-center">微信昵称</td>
      <td width="5%" class="text-center">用户组</td>
      <td width="10%" class="text-center">微信地址</td>
      <td width="10%" class="text-center">用户资料</td>
      <td width="8%" class="text-center">注册时间</td>
      <td width="10%" class=" text-center">操作</td>
    </tr>
    <?php
		$exec="SELECT u.*,g.groupname as levelname FROM `#@__user`  as u  left join `#@__usergroup`  as  g on u.level = g.id  where 1=1    ";
		if ($keyword != "") {
			if ($typeid == 'uid') {
				$exec .= "  AND u.id ='$keyword'  ";
		
			}
			if ($typeid == 'truename') {
				$exec .= "  AND u.truename like '%$keyword%'  ";
			}
			if ($typeid == 'nickname') {
				$exec .= "  AND   u.nickname like '%$keyword%'  ";
			}
			if ($typeid == 'mobile') {
				$exec .= "  AND  u.mobile  like '%$keyword%'   ";
			}
		}
		if ($u_level != '-1') {
			$exec .= "  AND  u.level='$u_level'   ";
		}
		
		//检查全局分页数
		if (empty($cfg_pagenum)) $cfg_pagenum = 20;
		$dopage->GetPage($exec, $cfg_pagenum);
		while($row = $dosql->GetArray())
		{
			$levelname=$row['levelname'];
			if($row['level']==2){
				$level_str='<span class="label label-success">'.$levelname.'</span>';
			}elseif($row['level']==3){
				$level_str='<span class="label label-danger">'.$levelname.'</span>';
			}else{
				$level_str=$levelname;
			}
			
			//sex
			$sex="";
			if($row['sex']=="1"){
				$sex="<span class='label label-danger'>男</span> ";
			}
			if($row['sex']=="2"){
				$sex="<span class='label label-info'>女</span>  ";
			}
			//address	
			$address="";
			if($row['country']!=""){
				$address.=$row['country']."-";
			}
			if($row['province']!=""){
				$address.=$row['province']."-";
			}
			if($row['city']!=""){
				$address.=$row['city'];
			}
			
			$manage_str='';
			if($row['level']==1){
				$manage_str='<a class="btn btn-success" href="manage_add.php?id='.$row['id'].'">设为授权服务站</a>';
			}elseif($row['level']==3){
				$manage_str='<a class="btn btn-danger" href="manage_update.php?id='.$row['id'].'">管理授权服务站</a>';
			}

			//抢单字眼
            $qiang="";
            if($row['qiang']=='1'){
			    $qiang='<br><br><span class="label label-success">可抢单</span>';
			}
			
		?>
    <tr align="left" class="dataTr">
      <td><?php echo $row['id']; ?></td>
      <td class="text-center"><span class="thumbs" style="width:100px;"><img src="<?php echo $row['headimgurl']; ?>" width="100" height="100" /></span></td>
      <td class="text-center"><?php echo $row['openid']; ?></td>
      <td class="text-center"><?php echo $sex.$row['nickname']?></td>
      <td class="text-center"><?php  echo $level_str;?></td>
      <td class="text-center"><?php echo $address;?></td>
      <td class="text-left"><?php  echo "单位：".$row['school']."<br>姓名：".$row['truename']."<br>手机：".$row['mobile'].$qiang;?></td>
      <td class="number text-center"><?php echo MyDate('Y-m-d H:i:s',$row['regtime']); ?></td>
      <td class="  text-center"><span><a class="btn btn-primary" href="member_update.php?id=<?php echo $row['id']; ?>">用户信息管理</a>
        </span></td>
    </tr>
    <?php

		}

		?>
  </table>
</form>
<?php



//判断无记录样式

if($dosql->GetTotalRow() == 0)

{

	echo '<div class="dataEmpty">暂时没有相关的记录</div>';

}

?>
<div class="page"> <?php echo $dopage->AjaxMemberPage(); ?> </div>
<?php



//判断是否启用快捷工具栏

if($cfg_quicktool == 'Y')

{

?>
<div class="quickToolbar">
  <div class="qiuckWarp">
    <div class="quickArea"><span class="pageSmall"> <?php echo $dopage->GetList(); ?> </span></div>
    <div class="quickAreaBg"></div>
  </div>
</div>
<?php

}

?>
</body>
</html>